<template>
  <div>
    <van-nav-bar class="ganavbar" title="企业查询" left-arrow @click-left="$router.go(-1)">
    </van-nav-bar>

    <div class="mainbody">
      <van-search v-model="keyword0" placeholder="请输入要查询的企业名称" @search="onSearch()" />
      <van-pull-refresh v-model="listObj.refreshing" @refresh="getList(listObj, 1)" class="scroll-list withSearchBar">
        <van-list v-model="listObj.loading" :finished="listObj.finished" finished-text="没有更多了" @load="getList(listObj)"
          class="listItems">
          <div class="item mdItem" v-for="(item, index) in listObj.list" :key="index" @click="showItemDetail(item)">
            <div class="title">邳州市辗庄体育总会</div>
            <div class="kvs">
              <div class="len"><div class="k">联系人:</div><div class="v">李鹏飞</div></div>
              <div class="len"><div class="k">联系电话:</div><div class="v">15913232421</div></div>
              <div class="len"><div class="k">企业地址:</div><div class="v">三里屯长江路123号个八大湾戈罗村13组5号</div></div>
            </div>
          </div>
        </van-list>
      </van-pull-refresh>
    </div>
    <router-view class="routerview"/>
  </div>
</template>
<script>
export default {
  name: "JCRW",
  components: {
  },
  data () {
    return {
      keyword0: '',
      keyword: '',
      listObj: {
        list: [],
        pagenum: 0,
        loading: false,
        finished: false,
        refreshing: false
      }
    };
  },
  methods: {
    showItemDetail: function (item) {
      this.$router.push({name: 'QYCX_DETAIL', params: {item, mode: 'view'}});
    },
    onSearch: function () {
      this.keyword = this.keyword0;
      this.getList(this.listObj, 1);
    },
    getList (obj, pagenum = 0) {
      var vm = this;
      if (pagenum) {
        obj.pagenum = pagenum;
      } else {
        obj.pagenum++;
      }
      obj.refreshing = false;
      // 如果第一页起  
      if (obj.pagenum == 1) {
        obj.list = [];
        obj.finished = false;
      }
      obj.loading = true;
      var filterValue = 'keyword=' + vm.keyword;
      vm.$getAndLoad('列表', 'getList.jsp?pagesize=10&pagenum=' + obj.pagenum + '&' + filterValue, function (data) {
        data.forEach(n => {
          obj.list.push(n);
        });
        if (data.length < 10) {
          obj.finished = true;
        }
        obj.loading = false;
      });
    }
  },
  mounted: function () {
  }
};
</script>

<style lang="scss" scoped>
</style>
